

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

public class UdpDictServer extends UdpEchoServer{

    private Map<String ,String > dict=new HashMap<>();


    public UdpDictServer(int port) throws SocketException {
        super(port);
        dict.put("小狗","dog");
        dict.put("小猫","cat");//插入英文单词
    }
    @Override//重写process,本质上就是翻译
    public String process(String request){
      return dict.getOrDefault(request,"该词不存在") ;
    }

    public static void main(String[] args) throws IOException {
        UdpDictServer server=new UdpDictServer(9090);
        server.start();
    }
}
